home *** CD-ROM | disk | FTP | other *** search
- /*-------------------------------------------------------------------
-
- AOCE Post Office Protocol (POP) / Simple Mail Transfer Protocol (SMTP)
- Mail Service Access Module
-
- written by Steve Falkenburg-- MacDTS
- ©1991-1993 Apple Computer, Inc.
-
- --------------
- change history
- --------------
-
- SJF 02/19/93 update for beta build b1
- SJF 10/29/92 update to a11 a11
- SJF 06/08/92 update to a8 a8
- SJF 02/15/92 first working version a4.5
- SJF 10/16/91 initial coding a3
-
- ---------------------------------------------------------------------*/
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #include <string.h>
-
- #include <MacTCPCommonTypes.h>
- #include <AddressXLation.h>
- #include "ConvertAddress.h"
- #include "network.h"
-
- pascal void DNRResultProc(struct hostInfo *hInfoPtr,char *userDataPtr);
-
- // ConvertStringToAddr
- //
- // a MacTCP call to get a host's IP number, given the name of the host
- //
- OSErr ConvertStringToAddr(char *name,unsigned long *netNum)
- {
- struct hostInfo hInfo;
- OSErr result;
- char done = 0x00;
- extern Boolean gCancel;
-
- result = InitRemoteNetStuff();
- if (result!=noErr)
- return result;
-
- if ((result = OpenResolver(nil)) == noErr) {
- result = StrToAddr(name,&hInfo,DNRResultProc,&done);
- if (result == cacheFault)
- while (!done)
- ; /* wait for cache fault resolver to be called by interrupt */
- CloseResolver();
- if ((hInfo.rtnCode == noErr) || (hInfo.rtnCode == cacheFault)) {
- *netNum = hInfo.addr[0];
- return noErr;
- }
- else
- result = hInfo.rtnCode;
- }
- *netNum = 0;
-
- return result;
- }
-
-
- // DNRResultProc
- //
- // completion routine for MacTCP name resolver calls
- //
- pascal void DNRResultProc(struct hostInfo *hInfoPtr,char *userDataPtr)
- {
- #pragma unused (hInfoPtr)
-
- *userDataPtr = 0xff; /* setting the use data to non-zero means we're done */
- }
-
-